<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet  version="1.0"
    xmlns:java="http://xml.apache.org/xslt/java"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" indent="no" encoding="UTF-8" omit-xml-declaration="yes" />

    
    <xsl:param name="q" select="q" />
    
    <xsl:template match="/">
        <div>Num docs: 
        <xsl:value-of select="/response/result[@name='response']/@numFound"/></div>
        <xsl:choose>
            <xsl:when test="/response/lst[@name='responseHeader']/int[@name='status'] = '0'">
                <xsl:if test="/response/result/doc" >
                    <xsl:call-template name="docs" />
                </xsl:if>        
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="/response/lst[@name='responseHeader']/str[@name='error']" />
            </xsl:otherwise>
        </xsl:choose>
        
    </xsl:template>

<xsl:template name="docs">
    <ul>
    <xsl:for-each select="/response/result/doc[./str[@name='title']!='&#160;']" >
        <li>
            <xsl:attribute name="class">result</xsl:attribute>
              <xsl:call-template name="doc" />
        </li>
    </xsl:for-each>
    </ul>
</xsl:template>

<xsl:template name="doc">
    <a>
        <xsl:attribute name="href">javascript:getPshKey('<xsl:value-of select="./str[@name='id']"/>', 'show');</xsl:attribute>
            <xsl:value-of select="./str[@name='title']"/>
    </a>&#160;
    <a title="save to invenio">
        <xsl:attribute name="href">javascript:getPshKey('<xsl:value-of select="./str[@name='id']"/>', 'save');</xsl:attribute>
        <img alt="save to invenio" src="img/save.png" border="0" />
    </a>
        <br/>(
        <xsl:value-of select="./str[@name='source']"/>)
</xsl:template>
</xsl:stylesheet>
